fn u322str(num: u32) -> char {
    match num {
        0..=9 => (num + 48) as u8 as char,
        10..16 => (num + 87) as u8 as char,
        _ => '?'
    }
}

pub fn convert_base(num_str: &str, to_base: u32) -> String {
    let cleaned = num_str.trim_matches(|c| c == ')');
    let parts: Vec<&str>  = cleaned.split('(').collect();
    let mut value1 = parts[0].parse::<u32>().unwrap();
    let in_base = parts[1].parse::<u32>().unwrap();
    let mut default_value = 0;
    let mut jin = 1;
    // println!("num_str: {}, cleaned: {}, value1: {},in_base: {}", num_str, cleaned, value1, in_base);
    while value1 > 0 {
        default_value += (value1 % 10) * jin;
        // println!("defaultValue: {}", defaultValue);
        value1 /= 10;
        jin *= in_base;
    }
    // println!("defaultValue: {}", defaultValue);
    let mut ret = String::new();
    while default_value > 0 {
        let one_digit = default_value % to_base;
        ret = format!("{}{}", u322str(one_digit), ret);
        default_value /= to_base;
    }
    ret
}
